﻿Public Class TakeoutOrder_Page
    Public Sub Initialize()
        TextBoxTime.Text = ""
        TextBoxAddress.Text = ""
        TextBoxOrderId.Text = ""
        TextBoxMenuId.Text = ""
        RadioButtonAdd.IsChecked = True
        RadioButtonRemove.IsChecked = False
    End Sub

    Private Sub ButtonOK_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles ButtonOK.Click
        Try
            GlobalClass.OrderCode = TakeoutServe.takeoutdishorder(Convert.ToDateTime(TextBoxTime.Text), TextBoxAddress.Text)
            TextBoxOrderId.Text = GlobalClass.OrderCode
            MsgBox("订单生成成功!")
        Catch err As Exception
            MsgBox(err.Message)
        End Try
    End Sub

    Private Sub ButtonReset_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles ButtonReset.Click
        Initialize()
    End Sub

    Private Sub ButtonAdd_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles ButtonAdd.Click
        Try
            If TextBoxOrderId.Text <> "" Then GlobalClass.OrderCode = TextBoxOrderId.Text
            TakeoutServe.takeoutdishorder(GlobalClass.OrderCode, TextBoxMenuId.Text, RadioButtonAdd.IsChecked)
            MsgBox("点菜或取消成功!")
        Catch err As Exception
            MsgBox(err.Message)
        End Try
    End Sub

    Private Sub TakeoutOrder_Page_KeyDown(sender As Object, e As System.Windows.Input.KeyEventArgs) Handles Me.KeyDown
        If e.Key = Key.Return Then ButtonOK_Click(sender, New RoutedEventArgs)
    End Sub
End Class
